Declare @dbid int,
@spid int,
@str nvarchar(128)

declare spidcurs cursor for
select session_id as spid from sys.dm_exec_sessions where login_name='$(STAGING_DATABASE_USERNAME)'
open spidcurs
fetch next from spidcurs into @spid

While @@fetch_status = 0
Begin
Select @str = 'Kill '+convert(nvarchar(30),@spid)
exec(@str)
--print @str

fetch next from spidcurs into @spid
End
Deallocate spidcurs
GO
